<%-- 
    Document   : Cart
    Created on : 2020-4-18, 18:37:26
    Author     : zhang
--%>

<%@page import="java.util.HashMap"%>
<%@page import="service.FindCart"%>
<%@page import="java.util.List"%>
<%@page import="entity.Book"%>
<%@page import="entity.Member"%>
<%@page import="dao.MemberDao"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%
            String name=(String)session.getAttribute("username");
        %>
        <h1>购物车</h1><h3><a href="BuyAll.jsp">全部购买</a></h3>
        <div style="position: absolute;left:300px;top:50px"><a href="Member.jsp?name=<%=name%>">返回个人主页</a></div>
        <%
            
            Member member=new MemberDao().getMemberByName(name);
            List<Book> list=new FindCart().findCart(member.getId());
            for(Book book:list){
                int count=new FindCart().findCartCount(member.getId(), book.getId());
                int i=1;
        %>
            <div>
                <h3><%=book.getBookName()%></h3>
                <div style="width: 200px;height:300px;border:1px solid #000">
                    <img src="img/<%=book.getCover()%>" width="200px" height="300px" alt="<%=book.getBookName()%>">
                </div>
                <div style="width: 300px;height:250px" >
                    <p>编号：<%=book.getId()%></p>
                    <p>作者：<%=book.getAuthor()%></p>
                    <p>数量：<%=count%></p>
                    <p>单价：<%=book.getPrice()%></p>
                    <form action="mcs?bookid=<%=book.getId()%>" method="post">
                        <button>修改数量</button>&nbsp;&nbsp;&nbsp;
                        <input type="text" value="1" name="count"><br>
                    </form>
                    <a href="gbbi?id=<%=book.getId()%>">查看更多</a>
                    <a href="dcas?id=<%=book.getId()%>">删除</a>&nbsp;&nbsp;&nbsp;
                    <a href="Buy.jsp?bookid=<%=book.getId()%>">购买</a>
                </div>
                
            </div>
                
            <%
                i++;
                }
            %>
    </body>
</html>
